package gnss

import (
	"fmt"
	"time"
)

// / 天线信息
type Gnss1033Rec struct {
	MsgId                   uint16
	StaId                   uint16
	AntennaDescriptor       string // <=31
	SetupID                 uint8
	AntennaSerialNumber     string // <=31
	ReceiverTypeDescriptor  string // <=31
	ReceiverFirmwareVersion string // <=31
	ReceiverSerialNumber    string // <=31
}

func (this *Gnss1033Rec) String() string {
	// 天线描述:ADVNULLANTENNA,
	// 天线序列号: 0,
	// 接收机类型描述: ,
	// 接收机固件版本: QXWZ VRS,
	// 接收机序列号: ,

	return fmt.Sprintf("[%d],StationID:%d,AntennaDescriptor:%s, %d,AntennaSerialNumber:%s,Receiver(type/firmware/serial):%s,%s,%s", this.MsgId, this.StaId, this.AntennaDescriptor, this.SetupID, this.AntennaSerialNumber,
		this.ReceiverTypeDescriptor, this.ReceiverFirmwareVersion, this.ReceiverSerialNumber)

}

func (this *Gnss1033Rec) String0() string {
	// 天线描述:ADVNULLANTENNA,
	// 天线序列号: 0,
	// 接收机类型描述: ,
	// 接收机固件版本: QXWZ VRS,
	// 接收机序列号: ,

	return fmt.Sprintf("StaId:%d,AntennaDescriptor:%s, %d,AntennaSerialNumber:%s,Receiver(type/firmware/serial):%s,%s,%s", this.StaId, this.AntennaDescriptor, this.SetupID, this.AntennaSerialNumber,
		this.ReceiverTypeDescriptor, this.ReceiverFirmwareVersion, this.ReceiverSerialNumber)

}

// / 电离层数据
type IgmasIonos struct {
	MsgId  int
	Alpha0 float64
	Alpha1 float64
	Alpha2 float64
	Alpha3 float64
	Beta0  float64
	Beta1  float64
	Beta2  float64
	Beta3  float64
}

// / 电离层数据 伽利略
type IgmasGalileoIonos struct {
	MsgId int
	Ai0   float64
	Ai1   float64
	Ai2   float64
	SF1   float64
	SF2   float64
	SF3   float64
	SF4   float64
	SF5   float64
}

// / 信息类型 31-BDS D1/D2 电离层参数
type Gnss31Bds struct {
	BDS_Alpha0 float64
	BDS_Alpha1 float64
	BDS_Alpha2 float64
	BDS_Alpha3 float64
	BDS_Beta0  float64
	BDS_Beta1  float64
	BDS_Beta2  float64
	BDS_Beta3  float64
}

// /  信息类型 32- BDS B-CNAV1/B-CNAV2 电离层参数
type Gnss32Bds struct {
	BDS_Alpha1 float64
	BDS_Alpha2 float64
	BDS_Alpha3 float64
	BDS_Alpha4 float64
	BDS_Alpha5 float64
	BDS_Alpha6 float64
	BDS_Alpha7 float64
	BDS_Alpha8 float64
	BDS_Alpha9 float64
}

// / RTCM 数据
type GnssRtcmData struct {
	MsgId    int
	TypeId   int
	Sys      byte
	Data     interface{}
	RtcmTime time.Time
	RefUtc   time.Time
	RawBuf   []byte // 包含头和CRC
}

const (
	TYPE_EPH        = 1
	TYPE_OBS        = 2
	TYPE_ionosphere = 3
	TYPE_STATION    = 5
	TYPE_RTCM       = 9
)

func NewGnssRtcmData(msgid int, typeid int, data interface{}) *GnssRtcmData {
	rval := &GnssRtcmData{
		MsgId:  msgid,
		TypeId: typeid,
		Data:   data,
	}
	return rval
}

func NewRtcmStationRec(msgid int) *GnssRtcmData {
	rval := &GnssRtcmData{
		MsgId:  msgid,
		TypeId: TYPE_STATION,
		Data:   &GnssStation{},
	}
	return rval
}
